<!doctype html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport"
        content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style rel="stylesheet">
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    .diy-title-box {
      position: relative;
      width: 100px;
      height: 100px;
      background: hotpink;
    }
    .diy-title-box::after {
      content: attr(data-tooltip);
      visibility: hidden;
      background-color: #333;
      color: #fff;
      text-align: center;
      border-radius: 4px;
      padding: 8px;
      position: absolute;
      z-index: 1000;
      bottom: 125%; /* 提示框位置 */
      left: 50%;
      transform: translateX(-50%);
      opacity: 0;
      transition: opacity 0.3s;
    }
    /*.diy-title-box:hover::after {*/
    /*  visibility: visible;*/
    /*  opacity: 1;*/
    /*}*/
  </style>
</head>
<body>
<div class="diy-title-box" data-tooltip="哈哈哈">112</div>
</body>
</html>
